package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.dto.SubprocessesDto;
import com.example.entity.dto.TicketDto;
import com.example.entity.dto.WorkOrderProcessDto;
import com.example.entity.hz.Tickets;
import com.example.entity.vo.SubprocessesVo;
import com.example.entity.vo.gd.CmsMqVoEnglish;
import com.example.entity.vo.gd.CraftVo;
import com.example.entity.vo.gd.TicketVo;
import com.example.entity.vo.gd.WorkOrderProcessVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TicketsMapper extends BaseMapper<Tickets> {

    @Select("SELECT * FROM CMSMQ WHERE MQ003 = #{mq003}")
    List<CmsMqVoEnglish> queryTicketDb(String mq003);

    @Select("SELECT * FROM CMSMD")
    List<com.mgkj.dao.share.vo.WorkCenterVo> queryWorkCenterVo();

    List<TicketVo> queryTicketIpAge(TicketDto ticketDto);

    @Select("SELECT A.TA001,A.TA002,A.TA003,A.TA004,MW002,A.TA005,B.TA021," +
            "MD002,A.TA008,A.TA009,A.TA010,A.TA034,A.TA051," +
            "'' AS MB002,A.UDF01,A.UDF02,A.UDF03, A.UDF04, A.UDF05, A.UDF51, A.UDF52 \n" +
            "FROM SFCTA A\n" +
            "LEFT JOIN MOCTA B ON A.TA001 = B.TA001 AND A.TA002 = B.TA002\n" +
            "LEFT JOIN CMSMD ON MD001 = B.TA021 \n" +
            "LEFT JOIN CMSMW ON MW001 = A.TA004 " +
            "WHERE A.TA001 = #{ta001} AND A.TA002 = #{ta002} " +
            "ORDER BY A.TA003")
    List<WorkOrderProcessVo> queryWorkOrderProcess(String ta001, String ta002);

    List<CraftVo> queryCraft(String division);

    Boolean deleteWorkOrderProcess(String ta001,String ta002,String ta003);

    Boolean insertOrUpdateWorkOrderProcess(List<WorkOrderProcessDto> workOrderProcessDtoList);

    Boolean deleteSubprocesses(String ta001,String ta002,String ta003);

    Boolean insertSubprocesses(SubprocessesDto subprocessesDto);

    List<SubprocessesVo> querySubprocesses(String ta001, String ta002, String ta003);
}
